using JT808Protocol.Abstracts;
using JT808Protocol.Methods;
using JT808Protocol.Models.JsonConverters;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Net.Http;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
using System.Threading.Tasks;

namespace JT808OnlineParser
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");

            builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
            var serilaizeOptions = new JsonSerializerOptions
            {
                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All),
                WriteIndented = true,
                IgnoreNullValues = true,
            };
            //serilaizeOptions.Converters.Add(new JT808DefaultConverter());
            builder.Services.AddSingleton(serilaizeOptions);
            builder.Services.AddSingleton<IJT808Parser, JT808Parser>();

            await builder.Build().RunAsync();
        }
    }
}